package com.test.demo;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * ${DESCRIPTION}
 *
 * @author muxiaoyu
 * @create 2017/06/06 15:40
 **/
public class Generic<T> {
    public Generic() {
        ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
        Type[] actualTypeArguments = pt.getActualTypeArguments();
        Class clazz = (Class) actualTypeArguments[0];
        System.out.println(clazz);
    }

    private T t;

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public static void main(String[] args) {
        Generic<String> objectGeneric = new Generic<String>();
        objectGeneric.setT("this is a string");
        if (objectGeneric instanceof Generic) {
            System.out.println("123");
        }
        System.out.println(objectGeneric.getT());
    }
}

class Generic01 extends Generic<Chiness> {
    public static void main(String[] args) {
        Generic01 generic01 = new Generic01();
    }
}
